package com.yc.springmvc;

import com.yc.springmvc.bean.Result;
import com.yc.springmvc.biz.BizException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Component
//控制器的增强   全局拦截
@RestControllerAdvice
public class MyExceptionHandle {

    @ExceptionHandler
    public Result handleBizException(BizException e){
        e.printStackTrace();
        return new Result(0,e.getMessage(),null);
    }

    @ExceptionHandler
    public Result handleBizException(Exception e){
        e.printStackTrace();
        return new Result(0,e.getMessage(),null);
    }

}
